<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'product.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>{{ 'product.breadcrumb.productJob' | translate }}</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="da-list-container ">
      <div class="da-list-header">
        <div class="d-input">
          <div class="inputIn">
            <input dTextInput style="width: 180px;" [error]="false" placeholder="工单编码" name="filterRole" class="me-2"
              [(ngModel)]="JobOrderNum">
            <input dTextInput style="width: 180px;" [error]="false" placeholder="物料编码" name="filterRole" class="me-2"
              [(ngModel)]="partNum">
            <input dTextInput style="width: 180px;" [error]="false" placeholder="物料名称" name="filterRole" class="me-2"
              [(ngModel)]="partName">
            <d-select style="width: 180px;" [options]="optionsStatus" placeholder="工单状态" [(ngModel)]="JobOrderStatus"
              class="me-2"></d-select>
            <d-range-datepicker-pro [(ngModel)]="rangeDate" (ngModelChange)="rangeDateChange($event)" name="rangeDate"
              [placeholder]="['制单时间-开始','制单时间-结束']" class="me-2"></d-range-datepicker-pro>
            <input dTextInput style="width: 180px;" [error]="false" placeholder="工单类型" name="filterRole" class="me-2"
              [(ngModel)]="JobOrderType">
            <div class="d-submit">
              <d-button id="primaryBtn" (click)="search2()"><i class="icon icon-filter-o me-2"></i>查询</d-button>
              <d-button bsStyle="common" (click)="reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
            </div>
          </div>
        </div>
        <div class="btn-group">
          <div class="btn-left">
            <d-button bsstyle="primaryBtn" routerLink="/pages/product/add-product-job"> <i
                class="icon icon-add me-2"></i>新增</d-button>
            <d-button bsStyle="danger" (btnClick)="deletes()"><i class="icon icon-delete me-2"></i>删除</d-button>
            <d-button bsStyle="common" (btnClick)="CompleteJobOrder()"><i
                class="icon icon-solved me-2"></i>结案</d-button>
            <d-button bsStyle="common" (btnClick)="unCompleteOrReopenJobOrder()"><i
                class="icon icon-infomation me-2"></i>反结案</d-button>
            <d-button bsStyle="common" (btnClick)="allLog()">日志</d-button>
            <d-button bsStyle="common" (btnClick)="printSelected()"><i class="icon icon-print me-2"></i>打印</d-button>
          </div>
        </div>
      </div>
      <div class="list-content">
        <d-data-table [dataSource]="tableData" [lazy]="true" [scrollable]="true" [fixHeader]="true"
          [tableWidthConfig]="tableWidthConfig" [tableOverflowType]="'auto'" 
          (checkAllChange)="getCheckedRows()" (rowCheckChange)="getCheckedRows()" [resizeable]="true">
          <thead dTableHead [checkable]="true">
            <tr dTableRow>
              <th dHeadCell [fixedLeft]="'80px'">
                <span>操作</span>
              </th>
              <th dHeadCell [fixedLeft]="colOption.fixedLeft" [fixedRight]="colOption.fixedRight"
                *ngFor="let colOption of dataTableOptions.columns" [title]="colOption.header">{{colOption.header}}</th>
            </tr>
          </thead>
          <tbody dTableBody>
            <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
              <tr dTableRow>
                <td dTableCell [fixedLeft]="'0px'">
                  <d-checkbox [disabled]="false" [showAnimation]="true" [ngModelOptions]="{ standalone: true }"
                    [ngModel]="rowItem.$checked" dTooltip [halfchecked]="rowItem.$halfChecked" [showGlowStyle]="false"
                    (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)"></d-checkbox>
                </td>
                <td dTableCell [rowItem]="rowItem" [fixedLeft]="'80px'">
                  <span><a class="devui-link" (click)="EditJob(rowItem.jobOrderId)"
                      [class.disabled]="rowItem.isApproval">维护</a></span>
                  <span class="ms-3"><a (click)="Approval(rowItem.jobOrderId)" class="devui-link"
                      [class.disabled]="rowItem.isApproval">核准</a></span>
                  <span class="ms-3"><a (click)="unApproval(rowItem.jobOrderId)" class="devui-link"
                      [class.disabled]="!rowItem.isApproval">反核准</a></span>
                  <span class="ms-3"><a (click)="viewJob(rowItem.jobOrderId)" class="devui-link">查看</a></span>
                  <span class="ms-3"><a (click)="delete(rowItem.jobOrderId)" class="devui-link-danger"
                      [class.disabled]="rowItem.isApproval">删除</a></span>
                </td>
                <td dTableCell [rowItem]="rowItem" [fixedLeft]="'300px'">
                  <span dTooltip [content]="rowItem.jobNum">{{rowItem.jobNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.saleOrderNum || '/'">{{rowItem.saleOrderNum || '/'}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.jobOrderType">{{rowItem.jobOrderType}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.productNum">{{rowItem.productNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.productName">{{rowItem.productName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.partType">{{rowItem.partType}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.uom">{{rowItem.uom}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.productionQuantity">{{rowItem.productionQuantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.receivedQuantity">{{rowItem.receivedQuantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <d-progress [percentage]="(rowItem.receivedQuantity / rowItem.productionQuantity) * 100">
                    <ng-template [dPosition]="'center'">
                      <div class="overflow-ellipsis" [title]="rowItem.receivedQuantity + '/' + rowItem.productionQuantity">
                        {{ rowItem.receivedQuantity }}/{{rowItem.productionQuantity}}
                      </div>
                    </ng-template>
                  </d-progress>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span *ngIf="!rowItem.isFinished" dTooltip [content]="rowItem.isAssign | booleanToText:'已派工':'未派工'">
                    <d-tag [tag]="rowItem.isAssign | booleanToText:'已派工':'未派工'" [labelStyle]="rowItem.isAssign"></d-tag>
                  </span>
                  <span *ngIf="rowItem.isFinished" dTooltip [content]="rowItem.isFinished | booleanToText:'已完工':'未完工'">
                    <d-tag [tag]="rowItem.isFinished | booleanToText:'已完工':'未完工'" [labelStyle]="rowItem.isFinished"></d-tag>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.isLocked | booleanToText:'已结案':'未结案'">
                    <d-tag [tag]="rowItem.isLocked | booleanToText:'已结案':'未结案'" [labelStyle]="rowItem.isLocked"></d-tag>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.jobOrderPlanStartDate">{{rowItem.jobOrderPlanStartDate}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.jobOrderPlanEndDate">{{rowItem.jobOrderPlanEndDate}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.jobOrderActualStartDate">{{rowItem.jobOrderActualStartDate}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.jobOrderActualEndDate">{{rowItem.jobOrderActualEndDate}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.orderPriority">{{rowItem.orderPriority}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span (click)="onButtonClick(rowItem)"><a class="devui-link">查看</a></span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.note">{{rowItem.note}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="'查看日志'" (click)="GetLogsByJobOrderId(rowItem.jobOrderId)">
                    <a class="devui-link">查看</a>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.creator">{{rowItem.creator}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem">
                  <span dTooltip [content]="rowItem.createTime">{{rowItem.createTime}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [fixedRight]="'0px'">
                  <span dTooltip [content]="rowItem.isApproval | isApproval">
                    <d-tag [tag]="rowItem.isApproval | isApproval" [labelStyle]="rowItem.isApproval"></d-tag>
                  </span>
                </td>
              </tr>
            </ng-template>
          </tbody>
        </d-data-table>
      </div>
      <div class="page-footer">
        <div>
          <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
            <a (click)="cleared()" class="clear">清空</a>
          </p>
        </div>
        <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true" [maxItems]="5"
          [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions" [(pageSize)]="pager.pageSize"
          [(pageIndex)]="pager.pageIndex" (pageIndexChange)="pageIndexChange($event)"
          (pageSizeChange)="pageSizeChange($event)">
        </d-pagination>
      </div>
    </div>

  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
